<?php
    class RiesgosController extends AppController {
        var $name = 'Riesgos';
        var $uses = array('Riesgo');
        var $helpers = array('Javascript');
        var $components = array('AdminParameters');

        function riesgos(){

            $tiposRiesgo = $this->Riesgo->TipoRiesgo->find("all");

            $this->set("tiposRiesgo", $tiposRiesgo);

            $this->render("riesgos", "ajax");
        }

        function  getList(){
            $this->render("list", "ajax");
        }

        function getListData($page=1, $limit=10, $orderColumn='fecha', $ascDesc='desc'){

            $model = "Riesgo.";

            $fields = array(
                 $model."id", $model."fecha"
            );

            $result = $this->AdminParameters->getListData($this->Evaluacion, $fields, $this->params["form"], $page, $limit, $orderColumn, $ascDesc);

            $this->set("result", $result);

            $this->render("/elements/ajax_return", "ajax");

        }

        function getDetail($op, $id){

            $this->set("operation", $op);
            $this->set("editId", $id);

            $this->render("detalle_riesgos", "ajax");

        }

        function getDetailData($id){
            $data = $this->Riesgo->find("all", array("conditions" => array("Riesgo.id" => $id), "recursive" => 0));

            $this->set("result", array("data" => $data));

            $this->render("/elements/ajax_return", "ajax");
        }

        function save(){

            if($this->AdminParameters->doSave($this->Riesgo, $this->params["form"])){
                $this->set("result", array("result" => true));
            }else{
                $this->set("result", array("result" => false));
                $this->set("result", array("error" => "Error while saving data."));
            }


            $this->render("/elements/ajax_return", "ajax");
        }

    }
?>